package com.campus.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket addDocket(Environment environment) {
//        Profiles profiles = Profiles.of("test", "dev");
//        boolean enable = environment.acceptsProfiles(profiles);

        return new Docket(DocumentationType.SWAGGER_2).apiInfo(addApiInfo())
                .groupName("琪亚娜")
                .enable(true)//关闭swagger
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.campus.web.controller"))//扫描指定包下的api注解
                .paths(PathSelectors.any())//
                .build();//创建
    }

    private ApiInfo addApiInfo() {
            Contact conta = new Contact("卫文辉","https://www.qynko.cn","1029659757@qq.com");
            return new ApiInfo(
                    "我的工作日志",
                    "写的很好",
                    "1.0",
                    "http://localohst:8080",
                    conta,
                    "11111111",
                    "www.baidu.com",
                    new ArrayList<>());
        }
}

